﻿@{
    ViewBag.Title = "OpPartition";
    Layout = "~/Views/Shared/_ViewFormPage.cshtml";
}
@section head{
    @if (false)
    {
        <script src="/Scripts/jquery-1.8.2.js"></script>
    }
    <script type="text/javascript">
        $(function () {
            $("input[readonly=readonly]").keydown(function (event) {
                if (event.keyCode == 8) {
                    return false;
                }
            });

            $("#btnSave").on("click", sendData);

        });


        function sendData() {
            if ($("form").valid()) {
                $('form').ajaxSubmit({
                    type: "post",
                    dataType: "json",
                    beforeSubmit: function() {
                        $("#btnSave").off("click", sendData);
                    },
                    success: function (callback) {
                        if (callback) {
                            $.ligerDialog.success('保存成功', function (yes) {
                                self.location.href = "/Product/OpPartition?op=add&pId=" + $("#ParentId").val();
                            });

                        }
                        else {
                            $.ligerDialog.error('保存失败');
                            $("#btnSave").on("click", sendData);
                        }
                    },
                    error: function (ex) {
                        $.ligerDialog.error('保存失败');
                        $("#btnSave").on("click", sendData);
                    }

                });
            }
        }
    </script>

}
@model PPartitionVM
<div id="header" class="header">
    <h4>产品分类 -- 添加</h4>
</div>
@using (Html.BeginForm("OpPartition", "Product", FormMethod.Post))
{
    <div id="detail_forms">
        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                所属模块
            </div>
            <div class="formItem textItem">
                @Html.TextBoxFor(model => Model.ParentName, new { @class = "texts", @readonly = "readonly" })
                @Html.HiddenFor(model => model.ParentId)
            </div>
            <div class="formItem msgItem">
            </div>
        </div>

        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                模块名称
            </div>
            <div class="formItem textItem">
                @Html.TextBoxFor(model => model.Name, new { @class = "texts" })
            </div>
            <div class="formItem msgItem">
                * 类别名称 6个字符以内
            </div>
        </div>

        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                模块描述
            </div>
            <div class="formItem textItem">
                @Html.TextBoxFor(model => model.Description, new { @class = "texts" })
            </div>
            <div class="formItem msgItem">
            </div>
        </div>

        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                是否启用
            </div>
            <div class="formItem textItem">
                @Html.CheckBoxFor(model => model.BEnabled, new { @class = "ifunny-checkbox" })
            </div>
            <div class="formItem msgItem">
            </div>
        </div>

        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                首页显示
            </div>
            <div class="formItem textItem">
                @Html.CheckBoxFor(model => model.BShowInt, new { @class = "ifunny-checkbox" })
            </div>
            <div class="formItem msgItem">
            </div>
        </div>

        <div class="formsItems clearfix">
            <div class="formItem labelItem">
                排序号
            </div>
            <div class="formItem textItem">
                @Html.TextBoxFor(model => model.SortNumber, new { @class = "texts" })
            </div>
            <div class="formItem msgItem">
                * 字段 排序号 必须是一个数字。
            </div>
        </div>

        <div id="btnContainer" class="formsItems">
            <div class="formItem labelItem">
                &nbsp;
            </div>
            <div class="formItem textItem">
                <a href="javascript:void(0);" id="btnSave">保存</a>
                <a href="@Url.Action("Partition")" id="btnCancel">取消</a>
            </div>
            <div class="formItem">
            </div>
        </div>
    </div>
    @Html.HiddenFor(model => model.PartitionId)
    @Html.HiddenFor(model => model.Level)
    @Html.HiddenFor(model => model.SortNumber)
    @Html.HiddenFor(model => model.HasChildren)
}